#!/usr/bin/perl
use warnings;
use strict;
use lib '/home/users/tex/perl_cruft/Data-Form/lib';
use Data::Form::Field::Text;
use Data::Form::Field::Option;
#use Data::Dumper;
#use Data::Dump qw/dump/;
#use YAML;

my $f = Data::Form::Field::Text->init( {  #name	   => 'name', 
			name	   => 'name',
			required   => 1,
			validators => {'%s must contain only word chars', sub {shift;/^(\w|\s)+$/ ? 1 : 0 } }, 
			}
		);
#print Dumper $f;
$f->fill_in('Harry Potter');

printf("%s '%s' is %s\n", $f, join("','" , $f->input ), $f ? 'valid' : 'invalid');

unless ( $f ){
        print "Reasons: \n";
        print "\t $_\n" for $f->errors;
}

#print Dump(\%$f);


my $sf = Data::Form::Field::Option->init(
{
   name      => 'before',
   required   => 1,
   options    => [ qw/Mr Mrs Ms Dr/]
}
);

$sf->fill_in('Sir');

printf("%s '%s' is %s\n", $sf, join("','" , $sf->input ), $sf ? 'valid' : 'invalid');

unless ( $sf ){
         print "Reasons: \n";
	 print "\t $_\n" for $sf->errors;
}	 

#print Dumper $sf;
#print dump $sf;

sub v {
        shift;
        /^(\w|\s)+$/ ? 1 : 0
}

__DATA__
package My::Form;

__PACKAGE__->add_field();
